Skip to content

fix(core): bind Mod-a to select all the document - #2975

Open
Asodariyasujal wants to merge 1 commit into
TypeCellOS:mainfrom
Asodariyasujal:main-fix-command+A-work-sujal
Open

fix(core): bind Mod-a to select all the document#2975
Asodariyasujal wants to merge 1 commit into
TypeCellOS:mainfrom
Asodariyasujal:main-fix-command+A-work-sujal

Conversation

@Asodariyasujal

@Asodariyasujal Asodariyasujal commented Aug 16, 2026

Copy link
Copy Markdown

BlockNote had no Mod-a binding, so select-all was left to the browser's native contenteditable handling and ProseMirror had to rebuild a document selection from the DOM selection it produced.

That fails when a block puts non-editable content first, which check list items do: the checkbox div sits ahead of the <p> holding the block's content. So in a document starting with a check list item, ProseMirror could not map the DOM selection to a valid position and dropped it, leaving the caret in place - Backspace then only edited that one block instead of clearing the document.

Now Mod-a sets an AllSelection itself, which selects every block type reliably and deletes down to a single empty paragraph.

Also stops getNearestBlockPos warning for the positions at the very start and end of the doc, which is where an AllSelection ends.

Summary by CodeRabbit

  • New Features

    • Added a keyboard shortcut for selecting all content in the editor using Ctrl/Cmd+A.
    • Select-all works across multi-block documents, including paragraphs, checklists, and math blocks.
  • Bug Fixes

    • Improved handling of selections at document boundaries, ensuring the first or last block is selected correctly.
  • Tests

    • Expanded coverage for keyboard shortcuts, full-document selection, and clearing selected content.

@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

@Asodariyasujal is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 179fc311-451b-4fa5-94f6-a5f327f24d75

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f48881c8-8d6d-40d9-8112-f4cc9a9ea21c

📥 Commits

Reviewing files that changed from the base of the PR and between eded970 and 5adfe7e.

📒 Files selected for processing (4)
  • packages/core/src/api/getBlockInfoFromPos.ts
  • packages/core/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts
  • packages/core/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts
  • packages/math-block/src/block/createReactMathBlockSpec.test.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The block information API now handles document-boundary positions. The keyboard shortcut extension maps Mod-A to full-document selection. Tests cover multi-block selection, clearing, block retrieval, and closed math-block shortcuts.

Changes

Document Boundary Resolution

Layer / File(s) Summary
Boundary position handling
packages/core/src/api/getBlockInfoFromPos.ts
The API resolves positions at or beyond document boundaries to the first or last top-level block when available.

Select-All Keyboard Handling

Layer / File(s) Summary
Editor select-all command and coverage
packages/core/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts, packages/core/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts, packages/math-block/src/block/createReactMathBlockSpec.test.tsx
The keyboard extension maps Mod-A to selectAll(). Tests dispatch shortcuts through ProseMirror and cover full-document selection, clearing, block retrieval, and closed math-block behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 5adfe

The change makes Mod-a reliably select the entire document, including documents beginning with checklist items, so clearing the document behaves consistently. No actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: nperez0111, yousefed

Poem

A rabbit taps Mod-A with care,
The whole block meadow becomes selected there.
Boundary hops find the first and last,
Math shortcuts keep their proper cast.
Backspace clears the leafy row—
Then default blocks sprout and grow.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the problem and solution but omits the required template sections for testing, checklist, screenshots, and additional notes. Add the missing template sections and document test coverage, existing-test results, checklist status, and any applicable screenshots or additional notes.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: binding Mod-a to select all document content.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

BlockNote had no `Mod-a` binding, so select-all was left to the browser's
native `contenteditable` handling and ProseMirror had to rebuild a document
selection from the DOM selection it produced.

That fails when a block puts non-editable content first, which check list
items do: the checkbox div sits ahead of the `<p>` holding the block's
content. So in a document starting with a check list item, ProseMirror
could not map the DOM selection to a valid position and dropped it, leaving
the caret in place - Backspace then only edited that one block instead of
clearing the document.

Now `Mod-a` sets an `AllSelection` itself, which selects every block type
reliably and deletes down to a single empty paragraph.

Also stops `getNearestBlockPos` warning for the positions at the very start
and end of the doc, which is where an `AllSelection` ends.
@Asodariyasujal
Asodariyasujal force-pushed the main-fix-command+A-work-sujal branch from dab8844 to 5adfe7e Compare August 19, 2026 10:11
@Asodariyasujal
Asodariyasujal marked this pull request as ready for review August 19, 2026 10:12
@Asodariyasujal

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant